__author__ = 'AndreyKa'

from selenium.webdriver.common.by import By
from php4dvd.pages.page import Page
from php4dvd.model.search_method import Search


class InternalPage(Page):
    """
    This is a common description of an internal page.
    """

    @property
    def logout_button(self):
        return self.driver.find_element(By.LINK_TEXT, 'Log out')

    @property
    def user_profile_link(self):
        return self.driver.find_element(By.LINK_TEXT, 'My profile')

    @property
    def search_field(self):
        return self.driver.find_element(By.XPATH, "//input[@id='q']")

    @property
    def add_movie(self):
        return self.driver.find_element(By.XPATH, "//*[@alt='Add movie']")

    @property
    def movie_finder(self):
        return self.driver.find_elements(By.XPATH, ".//div[@class='movie_box']")

    @property
    def result_finder(self):
        return self.driver.find_element(By.XPATH, "//*[contains(text(),'where found')]")

    @property
    def is_this_page(self):
        return self.is_element_visible((By.CSS_SELECTOR, "nav"))